<div class="findtrs">
	<form action="" class="layui-inline layui-form" method="post" style="width: 100%">
		{include file="cards/card_info_header"/}
		<div class="fremittanpred fbai" style="height: 450px;">
			{include file="cards/card_info_menu"/}
			<div class="list">
				<ul>
					<li>
						<label>增加金额 <i>*</i></label>
						<div class="rt">
							<h4>$</h4>
							<input type="text" class="info" name="amount" id="amount" value="" lay-verify="required|zint_cn" lay-verType="tips" placeholder="" >
						</div>
					</li>
					<li>
					</li>
				</ul>
			</div>
			<div style="color: red">
				*费用明细：增加金额+服务费</i><br /><br />
				*总计：<span id="total_money_show">$<span id="text_amount">? </span>+$<span id="text_amount_server">? * {$server_amount}</span> = <span id="text_amount_total">$ ?</span></span>
				<span style="color:#999999;padding-left: 100px;font-weight: bold;font-size: 20px;">账户余额: $ {$user_balance}</span>
			</div>
			<input type="hidden" value="{$card_id}" name="card_id">
			<input type="hidden" value="add_balance" name="type">
			<br />
			<div class="fbottonlst" style="float: left">
				<ul>
					<li class="on"><input type="button" class="fsubmit" lay-submit lay-filter="edit" style="float: left" value="提 交" ></li>
					<li><a href="{:url('cards/cardList')}">返回</a></li>
				</ul>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
	layui.use(['form'], function(){
		var form = layui.form;

		form.on('submit(edit)', function(data){
			var loading =layer.load(1, {shade: [0.1,'#fff']});
			JsPost("{:url('cards/cardAction')}", data.field, function(res){
				layer.close(loading);
				$('#amount').val('');
				if(res.code >0){
					layer.msg(res.msg, {time:1500}, function(){
						// window.location.reload();
						window.location.href = "{:url('cardList')}";
					});
				}else{
					layer.msg(res.msg , {time:1500});
				}
			})
		});

		$(function() {
			$('#amount').keyup(function () {
				defaultShow();
			});
			function defaultShow() {
				const fund_amount = $('#amount').val();
				const server_amount = "{$server_amount}";
				var total_money = parseFloat(fund_amount) + parseFloat(fund_amount)*parseFloat(server_amount);
				var total_money = total_money.toFixed(4);
				var total_money = parseFloat(total_money);
				$("#total_money_show").text("$" + fund_amount + " + " +
						"$(" + fund_amount + " * " + server_amount + ")" + " = " + total_money);
				if(fund_amount<=0){
					$("#total_money_show").text('0.00');
				}
			}
		});
	});
</script>